package com.diligreat.service; 

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.diligreat.domain.Selection;
import com.diligreat.mapper.SelectionMapper;

/**  
 * @Author Bruce 
 * @Date 2012-11-5
 * @Comments
 */
@Service
public class SelectionService {
	@Autowired
	private SelectionMapper selectionMapper;

	public void addSelection(Selection selection) {
		selectionMapper.addSelection(selection);
		
	}

	public List<Selection> listAll() {
		List<Selection> topList = selectionMapper.listTop();
		for (Selection selection : topList) {
			List<Selection> subList = selectionMapper.listSub(selection.getId());
			selection.setSubselection(subList);
		}
		return topList;
	}

	public void update(Selection selection) {
		selectionMapper.update(selection);
		
	}

	public void delete(long id) {
		selectionMapper.delete(id);
		selectionMapper.deleteLangByCataid(id);
		
	}
	

}
 